#include<stdio.h>
#include<unistd.h>

int main()
{
  //FILE* fp = fopen("log.txt","w");
  //FILE* fp = fopen("log.txt","r");
  FILE* fp = fopen("log.txt","a"); //append
  if(NULL == fp){
    perror("fopen");
    return 1;
  }
  
 // int ct = 5;
 // char buffer[64];
 // while(ct){
 //   fgets(buffer,sizeof(buffer),fp);

 //   printf(buffer);
 //   ct--;
 // }

  int ct = 5;
  while(ct){
    fputs("hello world\n",fp);
    ct--;
  }

  fclose(fp);

  return 0;
}

